import { fileURLToPath, URL } from "node:url"

import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
// import vueDevTools from 'vite-plugin-vue-devtools'
import autoImport from "unplugin-auto-import/vite"
import vueJsx from "@vitejs/plugin-vue-jsx"
import { visualizer } from "rollup-plugin-visualizer"

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    autoImport({
      imports: ["vue", "pinia", "vue-router"],
      dts: "types/auto-imports.d.ts",
      eslintrc: {
        enabled: true,
        filepath: "./.eslintrc-auto-import.json"
      }
    }),
    visualizer({
      open: true, // 构建完成后自动打开报告
      filename: "bundle-report.html", // 生成的报告文件名
      template: "treemap", // 可视化类型
      gzipSize: true, // 显示gzip压缩后大小
      brotliSize: true, // 显示brotli压缩后大小
      emitFile: false
    })
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url))
    }
  }
})
